//
//  NSString+TYUrl.m
//  TYBase_Example
//
//  Created by 谢航宇 on 2023/6/28.
//  Copyright © 2023 谢航宇. All rights reserved.
//

#import "NSString+TYUrl.h"

@implementation NSString (TYUrl)
+ (NSDictionary *)tyGetDictionaryFromUrlString:(NSString *)urlString {
     NSArray * urlArray = [urlString componentsSeparatedByString:@"?"];
     if (urlArray.count <2) {
          return @{};
     }
     NSArray * allArray = [urlArray[1] componentsSeparatedByString:@"&"];
     NSMutableDictionary * dic = [[NSMutableDictionary alloc]init];
     for (NSString * str in allArray) {
          NSArray * paragmaterArray = [str componentsSeparatedByString:@"="];
          if (paragmaterArray.count > 1) {
               [dic setObject:paragmaterArray[1] forKey:paragmaterArray[0]];
          }
     }
     return dic;
}

- (NSString *)tyToHtmlString {
     return [NSString stringWithFormat:@"<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title></title><style type=\"text/css\">array{display: flex;flex-direction: column;} string{word-wrap: break-word;}</style></head><body>%@</body></html>",self];
}
@end
